package com.geen.tuoke.ui.dialog

import android.content.Context
import androidx.databinding.DataBindingUtil
import com.geen.tuoke.R
import com.geen.tuoke.databinding.DialogDataImportBinding
import com.geen.tuoke.utils.ext.dp2px
import com.geen.tuoke.widget.dialog.DialogViewHolder
import com.geen.tuoke.widget.dialog.XXDialog

/**
 * @Author LuoJi
 * @Date 2021/12/30-16:50
 * @Desc 数据导入
 */
class DialogDataImport(context: Context,private val clickType:(type:String)->Unit) : XXDialog(context, R.layout.dialog_data_import) {

    private var mBinding: DialogDataImportBinding? = null

    companion object{

        const val TYPE_CAMERA = "CAMERA"
        const val TYPE_WECHATE = "WECHATE"
        const val TYPE_COMPUTER = "COMPUTER"

    }

    init {

        setWidthAndHeight(dp2px(288f), dp2px(300f))
        setCanceledOnTouchOutside(false)

    }

    override fun convert(holder: DialogViewHolder) {
        mBinding = DataBindingUtil.bind(holder.convertView)
        mBinding?.apply {

            viewClose.setOnClickListener {
                dismiss()
            }

            btnCancel.setOnClickListener {
                dismiss()
            }

            tvImportCamera.setOnClickListener {
                clickType(TYPE_CAMERA)
            }

            tvImportComputer.setOnClickListener {
                clickType(TYPE_COMPUTER)
            }

            tvImportWechat.setOnClickListener {
                clickType(TYPE_WECHATE)
            }

        }
    }
}